package com.woniuxy.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.entity.RbacMenu;
import com.woniuxy.mapper.RbacMenuMapper;
import com.woniuxy.service.RbacMenuService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 菜单表 服务实现类
 * </p>
 *
 * @author linKe
 * @since 2021-11-25
 */
@Service
public class RbacMenuServiceImpl extends ServiceImpl<RbacMenuMapper, RbacMenu> implements RbacMenuService {
    /**
     * 注入mapper持久层对象
     */
    @Resource
    private RbacMenuMapper rbacMenuMapper;


    @Override
    public List<RbacMenu> findAllPage(int currentPage, int size) {
        Page<RbacMenu> page = new Page<>(currentPage,size);
        return rbacMenuMapper.selectPage(page, null).getRecords();
    }

    @Override
    public RbacMenu findOneById(int id) {
        return rbacMenuMapper.selectById(id);
    }

    @Override
    public int addMenu(RbacMenu rbacMenu) {
        return rbacMenuMapper.insert(rbacMenu);
    }

    @Override
    public int updateMenu(RbacMenu rbacMenu) {
        return rbacMenuMapper.updateById(rbacMenu);
    }
    @Override
    public int deleteMenu(int id) {
        return rbacMenuMapper.deleteById(id);
    }

    @Override
    public List<RbacMenu> findAllMenu() {
        return rbacMenuMapper.selectList(null);
    }
}
